package com.lagou.task02;

public class FiveRow {

    //创建棋盘并返回
    public String[][] drawBoard(){
        String[][] board = new String[17][17];

        for(int i = 0; i < 17; i++){
            for(int j = 0; j < 17; j++){
                if (i == 0 && j == 0){
                    board[i][j] = " ";
                }else if(i == 0 && j != 0){
                    board[i][j] = Integer.toHexString(j-1);
                }else if(i != 0 && j == 0){
                    board[i][j] = Integer.toHexString(i-1);
                }else{
                    board[i][j] = "·";
                }
            }
        }

        for (int i = 0; i < 17; i++) {
            for (int j = 0; j < 17; j++) {
                System.out.print(board[i][j] + "\t");
            }
            System.out.println();
        }

        return board;
    }

    //更新棋盘并打印
    public void updateBoardAndPrint(String[][] board, int x, int y, Player player){
        board[x][y] = player.getChess();
        showBoard(board);
    }

    //打印棋盘
    public void showBoard(String[][] board){
        System.out.println("当前战况");
        for(int i = 0; i < 17; i++) {
            for (int j = 0; j < 17; j++) {
                System.out.print(board[i][j] + "\t");
            }
            System.out.println();
        }
    }
}
